package com.bionic.banking.commands;

import com.bionic.banking.auth.manager.Config;
import com.bionic.banking.auth.manager.Message;
import com.bionic.banking.dao.connection.LoggerLoader;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class CommandLogout implements ICommand {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse responce) {
        String page = null;
        //Free connection pool
        //ConnectionManager.getInstance().freeConnection();    

        //Get exising session
        HttpSession session = request.getSession(false);
        //Clear session
        if (session != null) {
            session.invalidate();
        }

        //Redirect to login page
        page = Config.getInstance().getProperty(Config.LOGIN);

        return page;
    }
}